/**
 * 抖音关注：程序员三丙
 * 知识星球：https://t.zsxq.com/j9b21
 */
package sanbing.example.dylike.application.rpc;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import sanbing.example.dylike.util.JacksonUtil;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RpcResponse {

    private boolean success;

    @SneakyThrows
    public static RpcResponse from(byte[] data) {
        return JacksonUtil.OBJECT_MAPPER.readValue(data, RpcResponse.class);
    }

    @SneakyThrows
    public byte[] toBytes() {
        return JacksonUtil.OBJECT_MAPPER.writeValueAsBytes(this);
    }
}